package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/3/14 11:49
 * @description
 */
public class Code3 {
    public static void main(String[] args) {
        System.out.println(new Code3().lengthOfLongestSubstring("nnnn"));
    }

    public int lengthOfLongestSubstring(String s) {
        int count = 0;
        StringBuilder temp = new StringBuilder();
        for (char c : s.toCharArray()) {
            if (!temp.toString().contains(c + "")) {
                temp.append(c);
            } else {
                temp = new StringBuilder(temp.substring(temp.indexOf(c + "") + 1) + c);
            }
            count = Math.max(count, temp.length());
        }
        return count;
    }

    private Byte convert(Integer i) {
        int n = i;
        return (byte)n;
    }
}
